//
//  main.m
//  Demo0020 
//
//  Created by zTercel on 13-1-30.
//  Copyright (c) 2013年 zTercel. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface NSMutableSet (NSPrinting)
-(void) print;
@end

@implementation NSMutableSet (NSPrinting)
-(void) print
{
    static int times = 0;
    NSMutableString* content = [NSMutableString stringWithFormat:@"print: %d\n obj cout: %ld ( ",times++, [self count]];
    for (id obj in self)
    {
        [content appendFormat: @"\"%@\" ", [obj description]];
    }
    [content appendString:@")"];
    NSLog(@"%@", content);
    
    return;
}

@end

int main(int argc, const char * argv[])
{
    @autoreleasepool {
        
        NSMutableSet* set = [[NSMutableSet alloc]initWithObjects:[NSNumber numberWithInt:100], @"set", nil];
        [set print];
        [set addObject:@"this is a mutableSet Object"];
        [set addObject:@"set1"];
        [set addObject:@"ztercel"];
        [set print];
        [set removeObject:@"set1"];
        [set print];
        NSLog(@"%@ contain object(set): %s", set, [set containsObject:@"set"] ? "Yes" : "No");
        [set removeAllObjects];
        [set print];
        
        [set setWithObjects: @"object", @"this", nil];
        
    }
    return 0;
}

